﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace COFE.Web.Services
{
    /// <summary>
    /// Interface for services that enables accessing an entry, it's properties, metadata and resources.
    /// </summary>
    [ServiceContract]
    public interface IEntryServices
    {     
        /// <summary>
        /// Return the entry that match the specified id.
        /// </summary>        
        /// <param name="entryID"></param>
        /// <returns></returns>
        [OperationContract]
        [WebGet(UriTemplate = "{entryID}?json={json}")]        
        Stream GetEntry(string entryID, string json);

        /// <summary>
        /// Return the entry that match the specified id.
        /// </summary>
        /// <param name="entryID"></param>
        /// <returns></returns>
        [OperationContract]
        [WebGet(UriTemplate = "{entryID}/?json={json}")]
        Stream GetEntry2(string entryID, string json);

        /// <summary>
        /// Create a new search that return a list of sub-entries synchronously.
        /// Redirects to search result.
        /// </summary>
        /// <param name="entryID"></param>
        /// <returns></returns>
        [OperationContract]
        [WebGet(UriTemplate = "{entryID}/list?json={json}&refresh={refresh}&page={page}")]
        Stream ListDirectory(string entryID, string refresh, string json, string page);

        /// <summary>
        /// Return a list of metadata of the entry.
        /// </summary>
        /// <param name="entryID"></param>
        /// <returns></returns>
        [OperationContract]
        [WebGet(UriTemplate = "{entryID}/metadata?json={json}")]
        Stream GetMetadata(string entryID, string json);

        /// <summary>
        /// Create and Redirect to entry type of this entry.
        /// rel and size supported, e.g. 
        /// /entries/ac25d769-426b-95b6-8163-85b8580490c5/entrytype?rel=icon&size=smallicon
        /// </summary>
        /// <param name="entryID"></param>
        /// <returns></returns>
        [OperationContract]
        [WebGet(UriTemplate = "{entryID}/type?rel={rel}")]
        void GetEntryType(string entryID, string rel);

        /// <summary>
        /// Return the specified propertyName of the entry, propertyName name is obtainable by the Links returned in an Entry.
        /// </summary>
        /// <param name="entryID"></param>
        /// <param name="propertyName"></param>
        /// <returns></returns>
        [OperationContract]
        [WebGet(UriTemplate = "{entryID}/{resource}?rel={rel}&json={json}")]
        Stream GetResource(string entryID, string resource, string rel, string json);

        /// <summary>
        /// Return the file stream of a file.
        /// </summary>
        /// <param name="entryID"></param>
        /// <returns></returns>
        [OperationContract]
        [WebGet(UriTemplate = "{entryID}/stream")]
        Stream GetFileStream(string entryID);

        /// <summary>
        /// Overwrite the file stream of a file by the specified fileContents.
        /// </summary>
        /// <param name="entryID"></param>
        /// <param name="fileContents"></param>
        [OperationContract]
        [WebInvoke(Method = "PUT", UriTemplate = "{entryID}/stream")]
        void SetFileStream(string entryID, Stream fileContents);


        //[OperationContract]
        //[WebInvoke(Method = "POST", UriTemplate = "{entryID}/refresh")]
        //void RefreshEntry(string entryID);

        //[OperationContract]
        //[WebInvoke(Method = "PUT", UriTemplate = "{entryID}")]
        //void UpdateEntry(string entryID, Stream entryStream);

        //[OperationContract]
        //[WebInvoke(Method = "DELETE", UriTemplate = "{entryID}")]
        //void DeleteEntry(string entryID);

    }
}
